package com.qf.fmall2202.index.controller;


import com.qf.fmall2202.index.entity.Category;
import com.qf.fmall2202.index.entity.IndexImg;
import com.qf.fmall2202.index.service.ICategoryService;
import com.qf.fmall2202.index.service.IIndexImgService;
import com.qf.fmall2202.product.entity.Product;
import com.qf.fmall2202.product.service.IProductService;
import com.qf.fmall2202.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.awt.*;
import java.util.List;

/**
 * <p>
 * 轮播图  前端控制器
 * </p>
 *
 * @author lzh
 * @since 2022-11-07
 */
@CrossOrigin
@RestController
@RequestMapping("/index")
public class IndexImgController {

    //2.依赖
    @Autowired
    IIndexImgService iIndexImgService;

    @Autowired
    ICategoryService categoryService;

    @Autowired
    IProductService productService;

    @GetMapping("/indeximg")
    public R indexImg(){


        List<IndexImg> data = iIndexImgService.getIndexImg();

        return R.ok().put("data",data);
    }

    @GetMapping("/category-list")
    public R categoryList(){

        List<Category> date = categoryService.categoryList();

        return R.ok().put("data",date);
    }

    @GetMapping("/list-recommends")
    public R listRecomends(){
        List<Product> data =  productService.listRecomends();

        return R.ok().put("data",data);

    }


    @GetMapping("/category-recommends")
    public R categoryRecommends(){

        List<Category> data =  categoryService.categoryRecommends();

        return R.ok().put("data",data);
    }
}
